package com.xneure.database.dialect;

import java.util.Date;
import com.xneure.utils.DateUtil;
import com.xneure.utils.StrUtil;

public class OracleDialect extends SqlDialect{
	public OracleDialect(){
	}

	@Override
	public String joint(String... str){
		return "CONCAT(".concat(StrUtil.join(str,","));
	}

	@Override
	public String paging(String sql,int start,int end){
		return String.format("select * from (select t.*,ROWNUM  ROWNUM_ from (%1s ) t where ROWNUM  <=%2s) b where ROWNUM_ >%3s",sql,end + start,start);
	}

	@Override
	public String batchSql(String sql){
		return "BEGIN\r\n".concat(sql).concat("\r\nEND;");
	}

	@Override
	public String toDate(Object _value){
		return "TO_DATE('" + DateUtil.dateFormat((Date)_value) + "','yyyy/mm/dd hh24:mi:ss')";
	}

	@Override
	public String toTimestamp(Object _value){
		return "TO_TIMESTAMP('" + DateUtil.dateFormat((Date)_value) + "','yyyy/mm/dd hh24:mi:ss.ff3')";
	}
}
